<?php

namespace App\maguttiCms\Middleware;

use Illuminate\Contracts\Foundation\Application;
use Illuminate\Http\Request;
use Closure;

class ForceSSLMiddleware
{
	protected $app;

	public function __construct(Application $app)
	{
		$this->app = $app;
	}

	/**
	 * Handle an incoming request.
	 *
	 * @param  \Illuminate\Http\Request  $request
	 * @param  \Closure  $next
	 * @return mixed
	 */
	public function handle($request, Closure $next)
	{
		if (env('APP_HTTPS', false)) {
			$this->app['request']->server->set('HTTPS', true);
		}

		return $next($request);
	}
}
